package com.lnsf.bookstore.web.user.controller;

import com.lnsf.bookstore.common.annotation.LoginUser;
import com.lnsf.bookstore.common.controller.ApiBaseAction;
import com.lnsf.bookstore.system.user.service.UserService;
import com.lnsf.bookstore.system.user.vo.User;
import com.lnsf.bookstore.web.user.service.ApiUserService;
import com.lnsf.bookstore.web.user.vo.ApiUser;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@RestController
@RequestMapping("/api/user")
public class ApiUserController extends ApiBaseAction{

    @Autowired
    private ApiUserService apiUserService;


    @RequestMapping("getIntegral")
    public Object getIntegral(@LoginUser ApiUser apiUser){
        Map<String,Object> resultObject = new HashMap<String, Object>();
        ApiUser apiUser1 = apiUserService.selectById(apiUser.getUserId());
        resultObject.put("apiUser",apiUser1);
        return toResponsSuccess(resultObject);
    }

    @RequestMapping("updateMoney")
    public int updateMoney(@LoginUser ApiUser apiUser, Integer money) {
        Map<String,Object> resultObject = new HashMap<String, Object>();
        resultObject.put("money",money);
        resultObject.put("id",apiUser.getUserId());
        int flat = apiUserService.updateMoney(resultObject);
        return flat;

    }




}
